import time
from concurrent import futures

import grpc
import counter_pb2,counter_pb2_grpc
_ONE_DAY_IN_SECONDS=60*60*24


class TestService(counter_pb2_grpc.CounterServiceServicer):
    def __init__(self):
        pass

    def hello(self,request,context):
        result=request.data+"this is gprc test service"
        list_result={"12":1232}
        return counter_pb2.Hellores(result=str(result),map_result=list_result)




def run():

    server=grpc.server(futures.ThreadPoolExecutor(max_workers=10))
    counter_pb2_grpc.add_CounterServiceServicer_to_server(TestService(),server)
    server.add_insecure_port('[::]:50052')
    server.start()
    print('start server...')
    try:
        while True:
            time.sleep(_ONE_DAY_IN_SECONDS)
    except  KeyboardInterrupt:
        server.stop(0)



if __name__ == '__main__':
    run()